package view.backing.Utils.Validator;

import java.util.Hashtable;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class EmailValidator implements Validator{
    
    
        public void validate(FacesContext facesContext, UIComponent uiComponent, Object object) throws ValidatorException{
            String dato = object.toString();
            if (!dato.matches("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")) {
                throw new ValidatorException(new FacesMessage("El e-mail tiene formato Incorrecto."));
            }
        }
}
